package sapling.dao;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import sapling.model.Markorder;
import sapling.model.OutboundOrder;
import sapling.model.Tree;

import java.util.Date;
import java.util.List;

/**
 * Created by mac on 17/7/17.
 */
public interface MarkorderDao extends JpaRepository<Markorder, Long> {
    List<Markorder> findBySalestate(int salestate);

    @Query(value = "SELECT * from markorder where salestate=?1 and hao_date <=?2",nativeQuery = true)
    List<Markorder> findHaodate(int salestate, String haodate);

    @Query(value = "SELECT count(id) from tree where sales_state=?1 and mark_id in " +
            "(SELECT id from markorder where salestate=?2)",nativeQuery = true)
    int findBySalestateTree(int sales_state, int salestate);
}
